package recursion;

class Point {
	protected final int x,y;
	private String name;
	public Point(int x, int y) {
		super();
		this.x = x;
		this.y = y;
//		this.name = markName();// 3.invoke subclass function
	}
	protected String markName() {
		return "[" + x + "," + y + "]";
	}
	@Override
	public String toString() {
		this.name = markName();
		return name;
	}
}
public class ColorPoint extends Point{
	private final String color;
	public ColorPoint(int x, int y, String color) {
		super(x, y);// 2.invoke supclass constrution
		this.color = color;// 5. init color value
	}
	@Override
	protected String markName() {
		// 4.execute before subclass constrution
		return super.markName() + ":" + this.color;
	}
	public static void main(String[] args) {
		// 1.invoke subclass construction
		System.out.println(new ColorPoint(3, 4, "red"));
	}
	
}